'Declare Function DestroyWindow Lib "user32" (ByVal hWnd As Long) As Long
'Declare Function CloseWindow Lib "user32" (ByVal hWnd As Long) As Long
'Send and close window api calls
Dim MhWnd As Long 'The hWnd of the window opened and closed
Declare Function PostMessage Lib "user32.dll" Alias "PostMessageA" (ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
'The two constants below are the message to send
'the first probalby uses proper methods (ie the ones a user would use) to close the window
'the second could just destroy the window and may leave the program running or still in memory
Public Const WM_CLOSE = &H10
'Public Const WM_DESTROY = &H2
'FindWindows declarations
Declare Function GetDesktopWindow Lib "user32.dll" () As Long
Declare Function GetWindow Lib "user32.dll" _
(ByVal hWnd As Long, ByVal uCmd As Long) As Long
Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" _
(ByVal hWnd As Long, ByVal lpString As String, ByVal nMaxCount As Long) As Long
Declare Function GetClassName Lib "user32.dll" Alias "GetClassNameA" _
(ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Declare Function GetParent Lib "user32.dll" (ByVal hWnd As Long) As Long
Declare Function GetWindowWord Lib "user32.dll" (ByVal hWnd As Long, _
ByVal nIndex As Long) As Integer
Global Const GW_HWNDNEXT = 2
Global Const GW_CHILD = 5
Global Const GWW_ID = (-12)
Function FindWindowLike(hWndArray() As Long, ByVal hWndStart As _
Long, WindowText As String, Classname As String, ID) As Integer
'FindWindowLike
' - Finds the window handles of the windows matching the specified
' parameters
'hwndArray()
' - An integer array used to return the window handles
'hWndStart
' - The handle of the window to search under.
' - The routine searches through all of this window's children and their
' children recursively.
' - If hWndStart = 0 then the routine searches through all windows.
'WindowText
' - The pattern used with the Like operator to compare window's text.
'ClassName
' - The pattern used with the Like operator to compare window's class
' name.
'ID
' - A child ID number used to identify a window.
' - Can be a decimal number or a hex string.
' - Prefix hex strings with "&H" or an error will occur.
' - To ignore the ID pass the Visual Basic Null function.
'Returns
' - The number of windows that matched the parameters.
' - Also returns the window handles in hWndArray()